package com.jxd.project.wzgl.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jxd.project.wzgl.dao.IGoodsDao;
import com.jxd.project.wzgl.dao.IGoodsLogDao;
import com.jxd.project.wzgl.dto.QueryGoodsLogDTO;
import com.jxd.project.menu.model.GoodsLog;
import com.jxd.project.wzgl.service.IGoodsLogService;
import com.jxd.project.wzgl.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName GoodsLogServiceImpl
 * @Description GoodsLog Service Implementation
 * @Author 刘成
 * @Date 2025/10/1 20:00
 * @Version 1.0
 */
@Service
public class GoodsLogServiceImpl extends ServiceImpl<IGoodsLogDao, GoodsLog> implements IGoodsLogService {
    @Autowired
    private IGoodsDao goodsDao;
    @Autowired
    private IGoodsLogDao goodsLogDao;
    @Autowired
    @Qualifier("goodsServiceImpl")
    IGoodsService goodsService;

    @Override
    public Map<String, Object> getGoodsLogWithQueryGoodsLogDTO(QueryGoodsLogDTO queryGoodsLogDTO){
        Page<GoodsLog> pager = new Page<>(queryGoodsLogDTO.getCurrent(),queryGoodsLogDTO.getSize());
        List<GoodsLog> list = goodsLogDao.selectGoodsLogWithQueryGoodsLogDTO(pager,queryGoodsLogDTO);
        int total = (int) pager.getTotal();
        Map<String,Object> map = new HashMap<>();
        map.put("total",total);
        map.put("data",list);
        return map;
    }

    @Override
    public boolean delLogByGoodsIds(List<Integer> goodsIds){
        return goodsLogDao.delLogByGoodsIds(goodsIds);
    }
}